﻿<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<title>Mind库存预警系统</title>
	<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
	<meta name="keywords" content="Mind库存预警系统">
	<meta name="discription" content="Mind库存预警系统">
	<link rel="stylesheet" type="text/css" href="css/common.css" />
	<link rel="stylesheet" type="text/css" href="css/system.css" />
	<!--		在标题栏的左侧显示图标 href:图标地址-->
	<link rel="icon" href="images/logo/favicon.ico" type="image/x-icon">
	<!--		在收藏夹里面显示图标 href:图标地址-->
	<link rel="shortcut icon" href="images/logo/favicon.ico" type="image/x-icon">
	<script src="js/jquery.min.js" type="text/javascript"></script>
	<!--下面一个开放的JS中有一个方法可以获取当前IP地址-->
	<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
	<script type="text/javascript">

		var ip=""; //所属的IP
		var cityAndAddress=""; //登录的地区
		$(function () {
			//获取IP,页面加载的时候自动执行
			ip=returnCitySN["cip"];
			cityAndAddress=returnCitySN["cname"];

			$("#ip").val(ip);
			$("#city").val(cityAndAddress);


			// $.ajax({
			// 	url: 'http://api.map.baidu.com/location/ip?ak=ia6HfFL660Bvh43exmH9LrI6',
			// 	type: 'POST',
			// 	dataType: 'jsonp',
			// 	success:function(data) {
			// 		//获取城市
			// 		cityAndAddress=data.content.address_detail.province + "," + data.content.address_detail.city;
			// 		//alert("IP:"+ip);
			// 		//alert("cityAndAddress:"+cityAndAddress);
			// 		//向表单中隐藏的字段赋值
			// 		$("#ip").val(ip);
			// 		$("#city").val(cityAndAddress);
			// 	}
			// });
		});

		//异步登录
		function userLogin() {
			var formData=$("#loginform").serialize();
			//alert(formData);
			$.ajax({
				url:"user_login",
				data:formData,
				type:"post",
				dataType:"json",
				success:function (result) {
					//alert(JSON.stringify(result));
					if(result.code==200){
						//alert("登录成功");
						location.href="page_index";
					}else if(result.code==500){
						alert("账号或密码错误!");
					}else if(result.code==501){
						alert("验证码错误!");
					}
				}
			});
		}

		//更换一个验证码
		function changeImage() {
			$("#imageCode").prop("src","createImage?date="+new Date());
		}

	</script>
</head>
<body id="loginpage">
<div id="login" class="clearfix">
	<div class="main clearfix">
		<div class="logbox">
			<div class="header" style="background-color: #2468a9;">
				Mind库存预警系统
			</div>
			<div class="web_login" id="web_login">
				<form id="loginform"  name="loginform" action="#" method="post" target="_self">
					<input type="hidden" id="ip" name="ip"/>
					<input type="hidden" id="city" name="city"/>
					<div class="inputOuter">
						<input type="text" placeholder="请输入您的账户" class="inputstyle" id="u" name="uno" value="" tabindex="1">
					</div>
					<div class="inputOuter">
						<input type="password" placeholder="请输入您的密码" class="inputstyle password" id="p" name="upass" value="" maxlength="16" tabindex="2">
					</div>
					<div class="inputOuter">
						<input type="text" placeholder="请输入您的验证码" class="inputstyle password" id="p" name="ucode" value="" maxlength="16" tabindex="2">
					</div>
					<div class="submit">
						<a class="login_button" href="#">
							<img src="createImage" onclick="changeImage();" id="imageCode"/>
							<input type="button" tabindex="6" value="登 录" class="btn" id="login_button" onclick="userLogin();">
						</a>
					</div>
				</form>
			</div>
<!--			<div class="footer">-->
<!--				<a href="javascript:void(0);" target="_blank" >忘了密码？</a>-->
<!--			</div>-->
		</div>

	</div>
</div>
</body>
</html>
